﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <div>
    <el-form ref="formRefTray" :model="stateTray.vmModel" label-width="100px">
      <el-row>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_TrayCode_FormItem" prop="Entity.TrayCode" :label="$t('message.autotrans._Model_Tray_TrayCode')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_Tray_TrayCode')}), trigger: 'blur' }]" >
            <el-input v-model="stateTray.vmModel.Entity.TrayCode" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_TrayName_FormItem" prop="Entity.TrayName" :label="$t('message.autotrans._Model_Tray_TrayName')">
            <el-input v-model="stateTray.vmModel.Entity.TrayName" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_TrayDescription_FormItem" prop="Entity.TrayDescription" :label="$t('message.autotrans._Model_Tray_TrayDescription')">
            <el-input v-model="stateTray.vmModel.Entity.TrayDescription" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_TrayStatus_FormItem" prop="Entity.TrayStatus" :label="$t('message.autotrans._Model_Tray_TrayStatus')">
            <el-input v-model="stateTray.vmModel.Entity.TrayStatus" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Note_FormItem" prop="Entity.Note" :label="$t('message.autotrans._Model_Tray_Note')">
            <el-input v-model="stateTray.vmModel.Entity.Note" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_TrayLine_FormItem" prop="Entity.TrayLine" :label="$t('message.autotrans._Model_Tray_TrayLine')">
            <el-input v-model="stateTray.vmModel.Entity.TrayLine" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_TrayStation_FormItem" prop="Entity.TrayStation" :label="$t('message.autotrans._Model_Tray_TrayStation')">
            <el-input v-model="stateTray.vmModel.Entity.TrayStation" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_UsedTimes_FormItem" prop="Entity.UsedTimes" :label="$t('message.autotrans._Model_Tray_UsedTimes')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_Tray_UsedTimes')}), trigger: 'blur' }]" >
            <el-input v-model="stateTray.vmModel.Entity.UsedTimes" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_PlannedTimes_FormItem" prop="Entity.PlannedTimes" :label="$t('message.autotrans._Model_Tray_PlannedTimes')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_Tray_PlannedTimes')}), trigger: 'blur' }]" >
            <el-input v-model="stateTray.vmModel.Entity.PlannedTimes" disabled clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

      <div style="text-align:right;">
        <WtmButton @click="onCloseTray"  type="primary" :button-text="$t('message.autotrans.SysClose')" style="margin-top:15px;"/>

      </div>

    </el-form>

  </div>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageBaseInformationTrayDetails;false">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { trayApi } from '/@/api/baseinformation/tray';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;


// 定义变量内容
const formRefTray = ref();
const stateTray = reactive({
    vmModel: {
	  Entity:{
        TrayCode: '',
        TrayName: '',
        TrayDescription: '',
        TrayStatus: '',
        Note: '',
        TrayLine: '',
        TrayStation: '',
        UsedTimes: null,
        PlannedTimes: null,
        ID:null,
      },

	},
    
});

// 取消
const onCloseTray = () => {
    closeDialog();
};

// 提交
const onSubmitTray = () => {
 	const loadingInstance = ElLoading.service({
		lock: true,
		text: '正在提交中，请等待。。。',
		background: 'rgba(0, 0, 0, 0.7)',
	});
   formRefTray.value?.validate((valid: boolean, fields: any) => {
		if (valid) {
            trayApi().edit(stateTray.vmModel).then(() => {
                ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
                emit('refresh');
                closeDialog();
            }).catch((error) => {
                other.setFormError(ci, error);
            }).finally(() => {
			loadingInstance.close();
		    })
		}
	})
};

// 页面加载时
onMounted(() => {
    
    if (ci.attrs["wtmdata"]) {
		stateTray.vmModel.Entity.ID = ci.attrs["wtmdata"].ID;
	}
	else if (useRouter().currentRoute.value.query.id) {
		stateTray.vmModel.Entity.ID = useRouter().currentRoute.value.query.id as any;
	}
	trayApi().get(stateTray.vmModel.Entity.ID ?? "").then((data: any) => other.setValue(stateTray.vmModel, data));
});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh','closeDialog']);
// 关闭弹窗
const closeDialog = () => {
    emit('closeDialog');
};
// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

